﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
using CMSMVC4.Filters;

namespace CMSMVC4.Areas.Main.Controllers
{
    public class MenuController : Controller
    {

        CMSMVC4Entities db = new CMSMVC4Entities();
        CommandSql cm = new CommandSql();

        [ChildActionOnly]
        public ActionResult ListMenuLoadParent(string id)
        {
            var data = cm.GetMenuParrent(MenuArea.Home,"Home");
            ViewBag.Menu = id;
            return PartialView(data);
        }

        [ChildActionOnly]
        public ActionResult ListMenuLoadParent2()
        {
            var data = cm.GetMenuParrent2(MenuArea.Home);
            return PartialView(data);
        }

        [ChildActionOnly]
        public ActionResult MenuSummary(int type)
        {
            var data = cm.GetSummary(type);
            return PartialView(data);
        }

        [ChildActionOnly]
        public ActionResult ListSlideShow()
        {
            var data = db.Slides.ToList();
            return PartialView(data);
        }

        [ChildActionOnly]
        public ActionResult LienHeMenu()
        {
            var data1 = db.Introductions.FirstOrDefault(x => x.Type == IntrotductionType.Phone);
            var data2 = db.Introductions.FirstOrDefault(x => x.Type == IntrotductionType.Email);
            ViewBag.data1 = data1;
            ViewBag.data2 = data2;
            return PartialView();
        }

        [ChildActionOnly]
        public ActionResult GetBanerleft(int type)
        {
            var data = db.Baners.Where(x=>x.Location == BanerStatus.Left && x.Type == type).ToList();
            return PartialView(data);
        }

        [ChildActionOnly]
        public ActionResult GetBanertop(int type)
        {
            var data = db.Baners.FirstOrDefault(x => x.Location == BanerStatus.Top && x.Type == type);
            return PartialView(data);
        }

        [ChildActionOnly]
        public ActionResult GetBanerContact()
        {
            var data = db.Baners.FirstOrDefault(x => x.Location == BanerStatus.Lienhe);
            return PartialView(data);
        }
    }
}
